package ro.gateway.aida.usr;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Date;
import java.util.Comparator;
import java.util.Properties;



/**
 * <p>Title: Romanian AIDA</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (comparator) 2003</p>
 * <p>Company: ro-gateway</p>
 * @author Mihai Popoaei, mihai_popoaei@yahoo.com, smike@intellisource.ro
 * @version 1.0-* @version $Id: User.java,v 1.1 2004/10/24 23:37:05 mihaipostelnicu Exp $
 */
public class User
{


      public static class UserComparator implements Comparator
      {
            public int compare( Object o1, Object o2 )
            {
                  User u1 = ( User ) o1;
                  User u2 = ( User ) o2;
                  return ( ( int ) ( u1.getId() - u2.getId() ) );
            }
      }

      public static class EmailComparator implements Comparator
      {
            public EmailComparator()
            {
            }

            public int compare( Object o1, Object o2 )
            {
                  User p1 = ( User ) o1;
                  User p2 = ( User ) o2;

                  return ( p1.getEmail().compareTo( p2.getEmail() ) );
            }
      }

      public static class CountryComparator implements Comparator
      {
            public CountryComparator()
            {
            }

            public int compare( Object o1, Object o2 )
            {
                  User p1 = ( User ) o1;
                  User p2 = ( User ) o2;

                  return ( p1.getCountryName().compareTo( p2.getCountryName() ) );
            }
      }

      public static class NameComparator implements Comparator
      {

            public NameComparator()
            {

            }

            public int compare( Object o1, Object o2 )
            {
                  User p1 = ( User ) o1;
                  User p2 = ( User ) o2;

                  return ( p1.getFullName().trim().compareTo( p2.getFullName().trim() ) );
            }
      }

      private long id = -1;
      private String login;
      private String pass;
      private String email;
      private String firstNames;
      private String lastName;
      private String workingLanguage;
      private String organization;
      private boolean standby = false;
      private boolean selected;
      //TODO:implement update
      private Date update;
      private String countryName;
      private String country_iso3;
      // dangerous field...
      // for registration purpose
      private String clear_password;

      public String getClear_password()
      {
            return clear_password;
      }

      public void setClear_password( String clear_password )
      {
            this.clear_password = clear_password;
      }

      public String getCountry_iso3()
      {
            return country_iso3;
      }

      public void setCountry_iso3( String country_iso3 )
      {
            this.country_iso3 = country_iso3;
      }

      public User()
      {
            selected = false;
      }

      public String getFullName()
      {
            return this.getFirstNames() + " " + this.lastName;
      }


      public void setStandby( boolean standby )
      {
            this.standby = standby;
      }

      public boolean isStandby()
      {
            return standby;
      }

      public void setWorkingLanguage( String workingLanguage )
      {
            this.workingLanguage = workingLanguage;
      }

      public String getWorkingLanguage()
      {
            return workingLanguage;
      }

      public long getId()
      {
            return id;
      }

      public void setId( long id )
      {
            this.id = id;
      }

      public void setLogin( String login )
      {
            this.login = login;
      }

      public String getLogin()
      {
            return login;
      }

      public void setPass( String pass )
      {
            this.pass = pass;
      }

      public String getPass()
      {
            return pass;
      }

      public void setEmail( String email )
      {
            this.email = email;
      }

      public String getEmail()
      {
            return email;
      }

      public void setFirstNames( String firstNames )
      {
            this.firstNames = firstNames;
      }

      public String getFirstNames()
      {
            return firstNames;
      }

      public void setLastName( String lastName )
      {
            this.lastName = lastName;
      }

      public String getLastName()
      {
            return lastName;
      }

      public String getOrganization()
      {
            return organization;
      }

      public void setOrganization( String organization )
      {
            this.organization = organization;
      }

      public static void main( String d[] )
      {
            Properties props = new Properties();
            try
            {
                  props.load( new FileInputStream( new File( "c:\\tmp\\a.properties" ) ) );
            }
            catch ( IOException e )
            {
                  e.printStackTrace(); //To change body of catch statement use Options | File Templates.
            }
//            System.out.println( props.getProperty( "a" ) );
      }

      /**
       * @return
       */
      public boolean isSelected()
      {
            return selected;
      }

      /**
       * @param b
       */
      public void setSelected( boolean b )
      {
            selected = b;
      }

      /**
       * @return
       */
      public String getCountryName()
      {
            return countryName;
      }

      /**
       * @return
       */
      public Date getUpdate()
      {
            return update;
      }

      /**
       * @param string
       */
      public void setCountryName( String string )
      {
            countryName = string;
      }

      /**
       * @param date
       */
      public void setUpdate( Date date )
      {
            update = date;
      }

}